package org.sdp.pearproject.controller;


import org.sdp.pearproject.controller.custom.*;
import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: ProjectCollectionController
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-12
 * @Version: 1.0
 * Table: pear_project_collection
 * Comment:
 * 项目-收藏表
 */
@RestController
@RequestMapping(value = "/project_collection")
public class ProjectCollectionController extends ProjectCollectionCustomController {
    static {
        addRequestClass("project_collection", "add", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionAddRequest.class);
        addRequestClass("project_collection", "add_encrypt", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionAddRequest.class);

        addRequestClass("project_collection", "update", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionUpdateRequest.class);
        addRequestClass("project_collection", "update_encrypt", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionUpdateRequest.class);

        addRequestClass("project_collection", "delete", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionDeleteRequest.class);
        addRequestClass("project_collection", "delete_encrypt", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionDeleteRequest.class);

        addRequestClass("project_collection", "query", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionQueryRequest.class);
        addRequestClass("project_collection", "query_encrypt", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionQueryRequest.class);

        addRequestClass("project_collection", "list", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionQueryRequest.class);
        addRequestClass("project_collection", "list_encrypt", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionQueryRequest.class);

        addRequestClass("project_collection", "count", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionQueryRequest.class);
        addRequestClass("project_collection", "count_encrypt", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionQueryRequest.class);

        addRequestClass("project_collection", "stat", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionQueryRequest.class);
        addRequestClass("project_collection", "stat_encrypt", "projectCollectionController", ProjectCollectionController.class, ProjectCollectionQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addProjectCollection(@MixRequestBody ProjectCollectionAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_collection", "add", request, callFromEncrypt);
        return super.addProjectCollection(request);
    }

    @PostMapping("/add_encrypt")
    public String addProjectCollectionEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectCollectionAddRequest request = (ProjectCollectionAddRequest) super.decrypt("project_collection", "add_encrypt", strRequest, ProjectCollectionAddRequest.class);
        Integer result = addProjectCollection(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateProjectCollection(@MixRequestBody ProjectCollectionUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_collection", "update", request, callFromEncrypt);
        return super.updateProjectCollection(request);
    }

    @PostMapping("/update_encrypt")
    public String updateProjectCollectionEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectCollectionUpdateRequest request = (ProjectCollectionUpdateRequest) super.decrypt("project_collection", "update_encrypt", strRequest, ProjectCollectionUpdateRequest.class);
        Integer result = updateProjectCollection(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteProjectCollection(@MixRequestBody ProjectCollectionDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_collection", "delete", request, callFromEncrypt);
        return super.deleteProjectCollection(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteProjectCollectionEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectCollectionDeleteRequest request = (ProjectCollectionDeleteRequest) super.decrypt("project_collection", "delete_encrypt", strRequest, ProjectCollectionDeleteRequest.class);
        Integer result = deleteProjectCollection(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public ProjectCollectionQueryResponse queryProjectCollection(@MixRequestBody ProjectCollectionQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("project_collection", "query", request, callFromEncrypt);
      return super.queryProjectCollection(request);
    }

    @PostMapping("/query_encrypt")
    public String queryProjectCollectionEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectCollectionQueryRequest request = (ProjectCollectionQueryRequest) super.decrypt("project_collection", "query_encrypt", strRequest, ProjectCollectionQueryRequest.class);
        ProjectCollectionQueryResponse result = queryProjectCollection(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<ProjectCollectionQueryResponse> listProjectCollection(@MixRequestBody ProjectCollectionQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_collection", "list", request, callFromEncrypt);
        if (super.needTotal("project_collection", "list", request)) {
            super.setTotal("project_collection", "list", request, super.countProjectCollection(request));
        }
        return super.listProjectCollection(request);
    }

    @PostMapping("/list_encrypt")
    public String listProjectCollectionEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectCollectionQueryRequest request = (ProjectCollectionQueryRequest) super.decrypt("project_collection", "list_encrypt", strRequest, ProjectCollectionQueryRequest.class);
        List<ProjectCollectionQueryResponse> result = listProjectCollection(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countProjectCollection(@MixRequestBody ProjectCollectionQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("project_collection", "count", request, callFromEncrypt);
      return super.countProjectCollection(request);
    }


    @PostMapping("/count_encrypt")
    public String countProjectCollectionEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectCollectionQueryRequest request = (ProjectCollectionQueryRequest) super.decrypt("project_collection", "count_encrypt", strRequest, ProjectCollectionQueryRequest.class);
        Integer result = countProjectCollection(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statProjectCollection(@MixRequestBody ProjectCollectionQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_collection", "stat", request, callFromEncrypt);
        return super.statProjectCollection(request);
    }

    @PostMapping("/stat_encrypt")
    public String statProjectCollectionEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectCollectionQueryRequest request = (ProjectCollectionQueryRequest) super.decrypt("project_collection", "stat_encrypt", strRequest, ProjectCollectionQueryRequest.class);
        BaseStatResponse result = statProjectCollection(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }


}
